{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import cv2\n",
    "img = cv2.imread('../../imags/test.jpeg',1)\n",
    "cv2.imwrite('../../imags/test_jpg.jpg',img,[cv2.IMWRITE_JPEG_QUALITY,50])  # [] 2 args，1 图片格式  2压缩比，范围0-100\n",
    "# jpg 有损压缩"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# png 无损压缩，1.无损  2.透明度属性\n",
    "cv2.imwrite('../../imags/test_png.png',img,[cv2.IMWRITE_PNG_COMPRESSION,0]) \n",
    "# jpg 0 数据越小压缩比越高0-100\n",
    "# png 0 数据越小压缩比越低0-9"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
